package com.ruoyi.pos.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.pos.domain.RejectOrder;
import com.ruoyi.pos.service.IRejectOrderService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * reject_orderController
 * 
 * @author wzh
 * @date 2021-05-20
 */
@RestController
@RequestMapping("/dev-api/system/pos/reject_order")
public class RejectOrderController extends BaseController
{
    @Autowired
    private IRejectOrderService rejectOrderService;

    /**
     * 查询reject_order列表
     */
//    @PreAuthorize("@ss.hasPermi('pos:order:list')")
    @GetMapping("/list")
    public TableDataInfo list(RejectOrder rejectOrder)
    {
        startPage();
        List<RejectOrder> list = rejectOrderService.selectRejectOrderList(rejectOrder);
        return getDataTable(list);
    }

    /**
     * 导出reject_order列表
     */
//    @PreAuthorize("@ss.hasPermi('pos:order:export')")
    @Log(title = "reject_order", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(RejectOrder rejectOrder)
    {
        List<RejectOrder> list = rejectOrderService.selectRejectOrderList(rejectOrder);
        ExcelUtil<RejectOrder> util = new ExcelUtil<RejectOrder>(RejectOrder.class);
        return util.exportExcel(list, "order");
    }

    /**
     * 获取reject_order详细信息
     */
//    @PreAuthorize("@ss.hasPermi('pos:order:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(rejectOrderService.selectRejectOrderById(id));
    }

    /**
     * 新增reject_order
     */
//    @PreAuthorize("@ss.hasPermi('pos:order:add')")
    @Log(title = "reject_order", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RejectOrder rejectOrder)
    {
        return toAjax(rejectOrderService.insertRejectOrder(rejectOrder));
    }

    /**
     * 修改reject_order
     */
//    @PreAuthorize("@ss.hasPermi('pos:order:edit')")
    @Log(title = "reject_order", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RejectOrder rejectOrder)
    {
        return toAjax(rejectOrderService.updateRejectOrder(rejectOrder));
    }

    /**
     * 删除reject_order
     */
//    @PreAuthorize("@ss.hasPermi('pos:order:remove')")
    @Log(title = "reject_order", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(rejectOrderService.deleteRejectOrderByIds(ids));
    }
}
